package com.such.kit.calendar.period.impl;

import java.text.ParseException;
import java.util.Calendar;
import com.such.kit.calendar.DateCalculate;
import com.such.kit.calendar.DatePeriodHelper;
import com.such.kit.calendar.period.DatePeriod;

public class Week5Period extends DatePeriod {

	public DatePeriod add(int amount) throws ParseException {
		return DatePeriodHelper.getInstance(DatePeriodHelper.FREQ_WEEK5, 
				super.sfd.format(DateCalculate.add(super.date, amount, DateCalculate.UNIT_WEEK)), super.format);
	}

	public DatePeriod subtract(int amount) throws ParseException {
		return DatePeriodHelper.getInstance(DatePeriodHelper.FREQ_WEEK5, 
				super.sfd.format(DateCalculate.subtract(super.date, amount, DateCalculate.UNIT_WEEK)), super.format);
	}

	public String firstFreqDay() {
		int amount = super.calendar.get(Calendar.DAY_OF_WEEK);
		return super.sfd.format(DateCalculate.subtract(super.date, amount, DateCalculate.UNIT_DAY));
	}

	public String lastFreqDay() {
		return DateCalculate.subtract(DateCalculate.add(firstFreqDay(), super.format, 1, DateCalculate.UNIT_WEEK), 
				super.format, 1, DateCalculate.UNIT_DAY);
	}

}
